<template>
  <div class="app-container">
    <el-dialog title="详情" :visible.sync="dialogVisible" width="50%" append-to-body>
      <el-form ref="form" :model="form" disabled>
        <el-row :gutter="10" style="display: flex;flex-wrap: wrap">
          <el-col :span="8">
            <el-form-item label="财务单号" prop="orderNo">
              <div>{{ form.orderNo }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="收入事项" prop="reOrderType">
              <dict-tag :options="dict.type.ims_receipt_matters_type" :value="form.reOrderType"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="关联单号" prop="reOrderNo">
              <div>{{ form.reOrderNo }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所属客户" prop="customerName">
              <div>{{ form.customerName }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="应收金额(元)" prop="incomes">
              <div>{{ form.incomes }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="已收金额(元)" prop="recvIncomes">
              <div>{{ form.recvIncomes }}</div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="状态" prop="orderStatus">
              <dict-tag :options="dict.type.ims_receipt_matters_status" :value="form.orderStatus"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="销售时间" prop="createTime">
              <div>{{ form.createTime }}</div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible=false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {addPayType, updatePayType} from "../../../../api/payMng";

export default {
  dicts:['ims_receipt_matters_type','ims_receipt_matters_status'],
  data() {
    return {
      flag: 0,
      titles: ['新增', '详情', '修改'],
      loading: false,
      dialogVisible: false,
      form: {}
    }
  },
  methods: {
    show(flag, form) {
      this.flag = flag
      this.dialogVisible = true
      this.resetForm('form')
      this.form = form
    },
    dialogOk() {
      this.$refs.form.validate(e => {
        if (e) {
          if (!this.flag) {
            this.loading = true
            addPayType(this.form).then(res => {
              this.dialogVisible = false
              this.$message.success('新增成功')
              this.$emit('ok')
            }).finally(e => {
              this.loading = false
            })
          } else {
            this.loading = true
            updatePayType(this.form).then(res => {
              this.dialogVisible = false
              this.$message.success('修改成功')
              this.$emit('ok')
            }).finally(e => {
              this.loading = false
            })
          }
        }
      })
    },
  }
}
</script>
